package com.sntk.commongetway.autho;

import com.alibaba.fastjson.JSONObject;
import com.sntk.commongetway.resp.ResponseData;
import com.sntk.commongetway.utils.RestTemplateUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.client.loadbalancer.LoadBalancerClient;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Component;

/**
 * @ClassName: AuthoService
 * @author: wgchao
 * @createTime: 2020/11/23 9:23 AM
 * @Description: TODO
 */
@Component
public class AuthoService {

    @Autowired
    private LoadBalancerClient loadBalancerClient;

    /**
     * 身份认证
     * @param accessToken
     * @return
     */
    public ResponseData autho(String accessToken){
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("accessToken", accessToken);
        ResponseEntity<ResponseData> resp = RestTemplateUtil.post(
                loadBalancerClient.choose("organ-autho-manager").getUri().toString()+"/sinohis/osm/interior/login/autho/passtoken",
                jsonObject, ResponseData.class);

        return resp.getBody();
    }
}
